//package com.weirblog.resource;
//
//import javax.enterprise.context.ApplicationScoped;
//import javax.ws.rs.Consumes;
//import javax.ws.rs.POST;
//import javax.ws.rs.Path;
//import javax.ws.rs.Produces;
//
//import com.weirblog.entity.Photo;
//import com.weirblog.entity.Users;
//import com.weirblog.util.BaseUtil;
//
////@Controller
////@RequestMapping("/user")
//@Path("user")
//@ApplicationScoped
//@Produces("application/json")
//@Consumes("application/json")
//public class UserController {
//
////	@Autowired
////	private UsersService usersService;
//	
////	@RequestMapping("/toAdmin")
////	public String toAdmin() {
////		return "/WEB-INF/blog/admin/main";
////	}
//	
////	@RequestMapping("/add")
////	public void add() {
////		Photo photo = new Photo();
////		photo.setName("dsadas");
////		photo.setThumbnail("dasdsad");
////		
////		Users u = new Users();
////		u.setEmail("332321321@qq.com");
////		u.setUserName(null);
////		u.setUserPwd("1113213123");
////		usersService.saveAndPhoto(u, photo);
////	}
////	@RequestMapping("/listUI")
////	public String listUI() {
////		return "/WEB-INF/blog/admin/user";
////	}
//	
//	@RequestMapping("/list")
//	@ResponseBody
//	public DataGrid<Users> list(UserVo userVo,Model model) {
//		Page<Users> users = usersService.queryPage(userVo.getPage(), userVo.getRows());
//		DataGrid<Users> dataGrid = new DataGrid<Users>(users.getTotalElements(), users.getContent());
//		return dataGrid;
//	}
//	@RequestMapping("/linkUser")
//	@ResponseBody
//	public void linkUser(String idStr,String userName,String profileImageUrl,HttpSession session) {
//		if (usersService.exitId(idStr.trim())) {
//			Users u = new Users(userName,idStr,profileImageUrl);
//			session.setAttribute("U", u);
//		}else {
//			Users u = new Users();
//			u.setIdStr(idStr.trim());
//			u.setUserName(userName.trim());
//			u.setProfileImageUrl(profileImageUrl.trim());
//			u.setEmail("1@qq.com");
//			u.setUserPwd("111111");
//			usersService.save(u);
//			session.setAttribute("U", u);
//			EmailSender.send("weiwei0620@qq.com", "有人注册",userName);
//		}
//	}
//	@ResponseBody
//    @RequestMapping("/checkemail")
//	public JsonVO checkemail(String email,HttpServletResponse response) {
//		JsonVO json = new JsonVO();
//    	Users u = usersService.findByEmail(email);
//    	if (u!=null) {
//			json.setSuccess(true);
//			json.setMsg("Y");
//		}else {
//			String random = BaseUtil.random();
//			Cookie cookie = new Cookie("emailCheck", random);
//	        cookie.setMaxAge(60*2);//2分钟
//	        cookie.setPath("/");
//	        response.addCookie(cookie);
//			
//	        try {
//				EmailSender.send(email.trim(), "爱威尔——验证码","爱威尔博客验证码："+random);
//				json.setSuccess(true);
//				json.setMsg("2分钟有效时间");
//			} catch (Exception e) {
//				json.setMsg("验证码获取失败，请重试看看");
//				e.printStackTrace();
//			}
//		}
//    	return json;
//	}
//	
//	@ResponseBody
//    @RequestMapping("/checkImg")
//    public JsonVO checkImg(String checkImg,String email,HttpServletRequest request) {
//    	JsonVO j = new JsonVO();
//		Cookie[] cookies = request.getCookies();
//		if (null!=cookies) {
//			for (Cookie cookie : cookies) {
//				if ("emailCheck".equals(cookie.getName())) {
//					if (BaseUtil.convertString(cookie.getValue()).equals(checkImg.trim())) {
//						Users u = new Users();
//						u.setUserName("qqqqq");
//						u.setEmail(email.trim());
//						u.setUserPwd("111111");
//						usersService.save(u);
//						j.setSuccess(true);
//						j.setMsg("验证通过，下次直接输入邮箱即可添加评论啦，么么哒！！！");
//						return j;
//					}
//				}
//			}
//		}
//    	return j;
//	}
//}
